{literal}
<h2>Raw SQL queries</h2>
These queries are very fast.
<pre class="code">
&lt;?php

// returns rows iterator
$result = DomSql::selectQuery('SELECT id,name FROM users');
foreach( $result as $row ) {
	echo $row['id'].' '.$row['name'].'&lt;br&gt;';
}

// returns only first found row
$row = DomSql::selectOneQuery( 'SELECT id,name FROM users LIMIT 1');
echo $row['id'].' '.$row['name'];


// returns only first found row only one value
$count = DomSql::selectOneQuery( 'SELECT count(*) as n FROM users LIMIT 1','n');
echo 'Total number of users: '.$count;


// this query returns defined value as key and others as array values
$result = DomSql::keyListQuery ('SELECT id,name FROM users','id');
foreach( $result as $id => $row ) {
	echo $id.' '.$row['name'].'&lt;br&gt;';
}

// this query returns defined value as key and name as value
$result = DomSql::keyListQuery ('SELECT id,name FROM users','id','name');
foreach( $result as $id => $name ) {
	echo $id.' '.$name.'&lt;br&gt;';
}


// for update, delete, insert etc request use this.
$result = DomSql::query('UPDATE someTable SET something=something WHERE id = something');

?&gt;
</pre>

<h2>DomSqlQuery Object </h2>
Basic DomSqlQuery looks like this. See DomSqlQuery CODE manual for all possible methods.
<pre class="code">
&lt;?php
$query = DomSqlQuery::c()
			->select('u.username, u.email, u.description, c.price as carPrice, c.name as carName')
			->from('users','u')
			->leftJoin('cars','c','c.driver=u.id')
			->where('c.price>10000')
			->where('c.price<20000') // where part will be c.price>10000 AND c.price<20000
			->matchAgainst('u.description','+Something -Cool','score','IN BOOLEAN MODE') 
				// MATCH (u.description) AGAINST ('+Something -Cool'). Also adds score to selected columns
			->orderBy('c.price DESC')
			->limit(100);
$commited = $query->commit();

// Foreaching using iterator. Iterator can only be looped through only ONCE! If you need more, use toArray method.
foreach( $commited as $row );

// Count all results. Makes extra query to database. (SELECT count(*) FROM ... )
$total = $commited->foundRows();

// You can also make SQL_COUNT_FOUND_ROWS count query.
$query->countFoundRows(true);
$commited = $query->commit();
$total = $commited->foundRows();


// Converting result to array
$result = $commited->toArray();


// If you need youre query as string
$string = (string)$query;

// If you need count query as string
$string = $query->toCountString();

?&gt;
</pre>

{/literal}